<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        body,ul,li{
            padding:0;
            margin:0;
            list-style:none;
        }
        li{
            width: 50px;
            height: 50px;
            background-color:yellowgreen;
            position:absolute;
            left:0;
            top:0;
        }
    </style>
</head>
<body>
<ul></ul>
<script src="../MyJs.js"></script>
<script>
    var Oul=document.getElementsByTagName("ul")[0];
    var str="";
    for(var i=0;i<26;i++){
        str+="<li></li>";
    }
    Oul.innerHTML=str;
    var links=document.getElementsByTagName("li");
    for(var i=0;i<links.length;i++){
        links[i].style.left=51*i+"px";
    }
    function doMove(element,step,end,atrr){
        clearInterval(element.timer);
        step=parseInt(getStyle(element,atrr))<end?step:-step;
        element.timer=setInterval(function(){
            var nowPosition=parseInt(getStyle(element,atrr))+step;
            if(parseInt(getStyle(element,atrr))>=end&&step>0||parseInt(getStyle(element,atrr))<=end&&step<0){
                nowPosition=end;
            }
            element.style[atrr]=nowPosition+"px";
            element.style.backgroundColor="rgb("+Math.round(Math.random()*255)+","+Math.round(Math.random()*255)+","+Math.round(Math.random()*255)+")";
            element.style.borderRadius="50%";
            if(parseInt(getStyle(element,atrr))===end){
                clearInterval(element.timer);
            }
        },30)
    }
    document.onclick=function(){
        var j=0;
        var tim=setInterval(function(){
            if(j<links.length){
                doMove(links[j],7,500,"top");
                j++;
            }
            if(j===links.length){
                clearInterval(tim);
            }
        },200)
    }
</script>
</body>
</html>